import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:photo_pipeline/photo_pipeline.dart';

import 'pipeline_providers.dart';

/// 分页数据（PageData<EnhancedFileInfo>）Provider，按分页参数提供数据流。
final mediaPageProvider = StreamProvider.family
    .autoDispose<PageData<EnhancedFileInfo>, PaginationParams>((ref, params) {
  final controller = ref.watch(pipelineControllerProvider);
  final coordinator = controller.camera.createEnhancedPaginationCoordinator(
    initialPagination: params,
  );

  ref.onDispose(() async {
    await coordinator.dispose();
  });

  return coordinator.stream;
});
